package com.hadoop.mapreduce.tablejoin.reducejoin;

import lombok.Data;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

@Data
public class InfoBean implements Writable{
    private int id;
    private String date;
    private String pid;
    private String amount;
    private String name;
    private String category_id;
    private double price;
    private int flag;
    public InfoBean() {
    }

    public void set(int id, String date, String pid, String amount, String name, String category_id, double price, int i) {
        this.id = id;
        this.date = date;
        this.pid = pid;
        this.amount = amount;
        this.name = name;
        this.category_id = category_id;
        this.price = price;
        this.flag=i;
    }

    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeInt(id);
        dataOutput.writeUTF(date);
        dataOutput.writeUTF(pid);
        dataOutput.writeUTF(amount);
        dataOutput.writeUTF(name);
        dataOutput.writeUTF(category_id);
        dataOutput.writeDouble(price);
    }

    public void readFields(DataInput dataInput) throws IOException {
        int id = dataInput.readInt();
        String date = dataInput.readUTF();
        String pid = dataInput.readUTF();
        String amount = dataInput.readUTF();
        String name = dataInput.readUTF();
        String category_id = dataInput.readUTF();
        double price = dataInput.readDouble();
    }


    @Override
    public String toString() {
        return "order_id=" + id + ", date=" + date + ", pid=" + pid + ", amount=" + amount + ", pname=" + name + ", category_id=" + category_id + ", price=" + price + ", flag=" + flag;
    }

    public void setOrder(int id, String date, String pid, String amount) {
        this.id = id;
        this.date = date;
        this.pid = pid;
        this.amount = amount;
    }
}
